package com.example.test.common;

import com.example.test.constants.ResultConstant;
import lombok.Data;

/**
 * @author ：dengjue
 * @date ：Created in 2021/3/28 14:39
 * @description ： 通用返回体
 */
@Data
public class ResultBody<T> {

    private Integer code;

    private String msg;

    private T data;

    public ResultBody(Integer code, String msg, T data){
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static ResultBody success(Object data){
        return new ResultBody(ResultConstant.SUCCESS,"success",data);
    }

    public static ResultBody fail(String msg){
        return new ResultBody(ResultConstant.FAIL,msg,null);
    }
}
